package Jdbc;
import java.sql.*;
import java.util.Scanner;
public class Work1 {
    public static void main(String[] args) {
        Connection conn = DBUtil.getConnection();
        PreparedStatement stmt = null;
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入学生的姓名、性别、手机号、QQ、微信、年级编号、入学日期、城市、出生日期、地址、密码");
        String sname = sc.next();
        String sex = sc.next();
        String tel = sc.next();
        String qq = sc.next();
        String wechat = sc.next();
        int grdid = sc.nextInt();
        String date = sc.next();
        String city = sc.next();
        String birthday = sc.next();
        String address = sc.next();
        String pass = sc.next();
        try {
            stmt = conn.prepareStatement("insert into s_student(sname,sex,telephone,qq,wechat,gradeid,enterdate,fromcity,birthday,address,pass) values(?,?,?,?,?,?,?,?,?,?,?) ");
            stmt.setString(1, sname);
            stmt.setString(2, sex);
            stmt.setString(3, tel);
            stmt.setString(4, qq);
            stmt.setString(5, wechat);
            stmt.setInt(6, grdid);
            stmt.setString(7, date);
            stmt.setString(8, city);
            stmt.setString(9, birthday);
            stmt.setString(10, address);
            stmt.setString(11, pass);
            System.out.println(stmt.executeUpdate());
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(conn, stmt, null);
        }
    }
}
